package com.hjm.project.agentInfo.agentPaid.controller;

import java.util.List;

import com.hjm.project.agentInfo.agentPaid.domain.AgentPaid;
import com.hjm.project.agentInfo.agentPaid.service.IAgentPaidService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * AgentPaidController
 * 
 * @author maker-platform
 * @date 2021-03-22
 */
@Controller
@RequestMapping("/AgentPaid/agentPaid")
public class AgentPaidController extends BaseController
{
    private String prefix = "agentInfo/agentPaid";

    @Resource
    private IAgentPaidService agentPaidService;

    @RequiresPermissions("AgentPaid:agentPaid:view")
    @GetMapping()
    public String agentPaid()
    {
        return prefix + "/agentPaid";
    }

    /**
     * 查询AgentPaid列表
     */
    @RequiresPermissions("AgentPaid:agentPaid:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AgentPaid agentPaid) throws Exception {
        agentPaid.setProfitType("6");
        startPage();
        List<AgentPaid> list = agentPaidService.selectAgentPaidList(agentPaid);
        return getDataTable(list);
    }

    /**
     * 导出AgentPaid列表
     */
     @RequiresPermissions("AgentPaid:agentPaid:export")
    @Log(title = "AgentPaid", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AgentPaid agentPaid) throws Exception {
        List<AgentPaid> list = agentPaidService.selectAgentPaidList(agentPaid);
        ExcelUtil<AgentPaid> util = new ExcelUtil<AgentPaid>(AgentPaid.class);
        return util.exportExcel(list, "提现奖励明细");
    }

    /**
     * 新增AgentPaid
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存AgentPaid
     */
    @RequiresPermissions("AgentPaid:agentPaid:add")
    @Log(title = "AgentPaid", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AgentPaid agentPaid)
    {
        return toAjax(agentPaidService.insertAgentPaid(agentPaid));
    }

    /**
     * 修改AgentPaid
     */
    @GetMapping("/edit/{settleSerial}")
    public String edit(@PathVariable("settleSerial") String settleSerial, ModelMap mmap)
    {
        AgentPaid agentPaid = agentPaidService.selectAgentPaidById(settleSerial);
        mmap.put("agentPaid", agentPaid);
        return prefix + "/edit";
    }

    /**
     * 修改保存AgentPaid
     */
    @RequiresPermissions("AgentPaid:agentPaid:edit")
    @Log(title = "AgentPaid", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AgentPaid agentPaid)
    {
        return toAjax(agentPaidService.updateAgentPaid(agentPaid));
    }

    /**
     * 删除AgentPaid
     */
    @RequiresPermissions("AgentPaid:agentPaid:remove")
    @Log(title = "AgentPaid", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(agentPaidService.deleteAgentPaidByIds(ids));
    }
}
